package 公司真题.美团;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class _晋级人数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String oneLine = sc.nextLine().trim();
        String[] strArr = oneLine.split(" ");
        int peopleCount = Integer.parseInt(strArr[0]);
        int jinjiCount = Integer.parseInt(strArr[1]);
        String twoLine = sc.nextLine().trim();
        strArr = twoLine.split(" ");
        Integer[] arr = new Integer[ peopleCount];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Integer.parseInt(strArr[i]);
        }
        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        int shiji_jinji_renshu = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 0 && arr[i] >= arr[jinjiCount]) {
                shiji_jinji_renshu++;
            }else {
                break;
            }
        }
        System.out.println(shiji_jinji_renshu);
    }
}
